import configparser
import os


class PropertiesReader:
    def __init__(self):
        self.properties = configparser.ConfigParser()
        current_file_path = os.path.abspath(__file__)
        current_dir_path = os.path.dirname(current_file_path)
        project_root_path = os.path.dirname(current_dir_path)
        project_root_path = os.path.dirname(project_root_path)
        properties_file_path = os.path.join(project_root_path, 'settings.properties')
        with open(properties_file_path, 'r') as file:
            file_content = '[default]\n' + file.read()  # 添加虚拟节
            self.properties.read_string(file_content)

    def get_property(self, key):
        return self.properties.get('default', key)
